//
//  InstallLayer.h
//  client
//
//  Created by sg on 2/17/17.
//
//

#ifndef InstallLayer_h
#define InstallLayer_h

#include "cocos2d.h"
#include "editor-support/cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
#include "CCFactory.h"
#include "network/HttpClient.h"



using namespace cocos2d;
using namespace dragonBones;

Scene* createInstallScene();

class InstallLayer : public cocos2d::Layer
{
public:
    CREATE_FUNC(InstallLayer);
    InstallLayer();

    virtual ~InstallLayer();    
    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    virtual bool init();
    virtual void onEnterTransitionDidFinish();
    virtual void onExit();
    
    virtual void onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event);
    
    virtual void goStart();
    virtual void goExit();
    virtual void goNext();
    
    virtual void update(float dt);
    
	void runMainLua();
    
    void updateProgressBar(int p);
    void updateStageLabel(const std::string& s);
    void updateProgressLabel(const std::string& s);
    void setLoadingVisible(bool isVisible);
    
protected:
    void _updateLoadingBarVisible();
    void _beforeGoStart();
    
    void _requestReviewState();
    void _onReviewStateResponded(network::HttpClient *sender, network::HttpResponse *response);
    
private:
   
    ui::Text* _progressLabel;
    ui::Text* _assetIdLabel;
    ui::LoadingBar* _loadingBarTotal;
    ui::LoadingBar* _loadingBarFile;
    Node* _loadingBarLight;
    Node* _loadingPanel;
    ui::Layout * _blackLayer;
protected:
    bool _updateSuccess;
};

#endif
